package org.wishwork.api.supplier.query;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.ExtendBase;

import java.util.List;

/**
 * @description:
 * @author: WangYX
 * @create: 2022-04-08 15:52
 * @Version: 1.0.0
 **/
@Getter
@ToString
@EqualsAndHashCode
public class SupplierQueryRequest extends ExtendBase {

    /**
     * 供应商编码
     */
    private List<String> supplierCodes;

    protected SupplierQueryRequest(Integer pageIndex, Integer pageSize, String modifiedBegin, String modifiedEnd, List<String> supplierCodes) {
        super(pageIndex, pageSize, modifiedBegin, modifiedEnd);
        this.supplierCodes = supplierCodes;
    }


    public static Builder builder() {
        return new Builder();
    }

    @Override
    public Builder toBuilder() {
        return new Builder().pageIndex(this.pageIndex)
                .pageSize(this.pageSize).modifiedBegin(this.modifiedBegin)
                .modifiedEnd(this.modifiedEnd).supplierCodes(this.supplierCodes);
    }

    public static class Builder extends ExtendBase.Builder<Builder, SupplierQueryRequest> {

        private List<String> supplierCodes;

        @Override
        public Builder modifiedBegin(String modifiedBegin) {
            this.modifiedBegin = modifiedBegin;
            return this;
        }

        @Override
        public Builder modifiedEnd(String modifiedEnd) {
            this.modifiedEnd = modifiedEnd;
            return this;
        }

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder supplierCodes(List<String> supplierCodes) {
            this.supplierCodes = supplierCodes;
            return this;
        }

        @Override
        public SupplierQueryRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageIndex < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 30 : this.pageSize < 0 ? 30 : this.pageSize;
            return new SupplierQueryRequest(this.pageIndex, this.pageSize, this.modifiedBegin, this.modifiedEnd, this.supplierCodes);
        }
    }


}
